var map;

function init() {

    // http://maps5.trimet.org/bh/geoserver/wfs?service=WFS&srsName=epsg:4326&version=1.0.0&request=GetFeature&typeName=trimet:bike_route&maxFeatures=5000
    // http://maps5.trimet.org/bh/geoserver/wfs?service=WFS&&propertyName=street_id,geom&srsName=epsg:4326&version=1.0.0&request=GetFeature&typeName=trimet:bike_route&maxFeatures=500
    map = new OpenLayers.Map({
        div: "map",
        layers: [
            new OpenLayers.Layer.WMS(
                "Natural Earth", 
                "http://maps5.trimet.org/wms/reflect",
                {layers: "currentOSPN"}
            )
        ],
        center: new OpenLayers.LonLat(-122.5, 45.5),
        zoom: 12
    });

    proto = new OpenLayers.Protocol.WFS({
        //url:  "/bh/geoserver/wfs",
        url:  "wfs-medium.xml",
        geometryName: "geom",
        featureType: "bike_route",
        multipleSelect: true,
        propertyName: ["street_id", "geom"],
        srsName:"EPSG:4326",
        srsNameInQuery:true,
        featureNS: "http://maps.trimet.org/trimet"
    });
    
    vectors = new OpenLayers.Layer.Vector("WFS", {
        strategies: [new OpenLayers.Strategy.BBOX()],
        protocol: proto, 
        styleMap : new OpenLayers.StyleMap({
            "default": new OpenLayers.Style({
//                pointRadius: "${type}", // sized according to type attribute
                fillColor: "#ffcc66",
                strokeColor: "#ff9933",
                strokeWidth: 4,
                graphicZIndex: 1,
                fillOpacity: 0.80
            }),
            "temporary": new OpenLayers.Style({
                fillColor: "#66ccff",
                strokeColor: "#3399ff",
                strokeWidth: 4,
                graphicZIndex: 2,
                cursor : "pointer", 
                fillOpacity: 0.60
            }),
            "select": new OpenLayers.Style({
                fillColor: "#66ccff",
                strokeColor: "#3399ff",
                strokeWidth: 4,
                graphicZIndex: 2,
                fillOpacity: 0.80
            })
        })
/*
        ,
        filter: new OpenLayers.Filter.Logical({
        type: OpenLayers.Filter.Logical.OR,
        filters: [
            new OpenLayers.Filter.Comparison({
                type: OpenLayers.Filter.Comparison.EQUAL_TO,
                property: "TYPE",
                value: "highway"
            }),
            new OpenLayers.Filter.Comparison({
                type: OpenLayers.Filter.Comparison.EQUAL_TO,
                property: "TYPE",
                value: "road"
            })
        ]
    })
*/
    });

    map.addLayers([vectors]);
    ctl = new Base.SelectControl({map:map, layers:[vectors]});
/*
    var report = function(e) {
        console.log(e.type, e.feature.id);
    };

    var highlightCtrl = new OpenLayers.Control.SelectFeature(vectors, {
        hover: true,
        highlightOnly: true,
        renderIntent: "temporary",
        eventListeners: {
            beforefeaturehighlighted: report,
            featurehighlighted:       report,
            featureunhighlighted:     report
        }
    });

    var selectCtrl = new OpenLayers.Control.SelectFeature(vectors,
        {clickout: true}
    );

    map.addControl(highlightCtrl);
    map.addControl(selectCtrl);

    highlightCtrl.activate();
    selectCtrl.activate();
    console.log('hi there');
*/
}
